/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.afaker.searth.core.index.handler;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.lucene.document.Document;

/**
 *
 * @author bruce
 */
public class Mp3Handler extends DocumentHandler {

    @Override
    public Document getDocument(File file) {
        FileInputStream reader = null;

        Document doc = new Document();
        String info = "";
        try {
            reader = new FileInputStream(file);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Mp3Handler.class.getName()).log(Level.SEVERE, null, ex);
        } 

        if(reader != null){
            try {

                int b;
                byte[] buf = new byte[256];
                reader.read(buf, 10, 30);
                for (int i = 0; i < buf.length; i++) {
                    byte c = buf[i];
                    System.out.print((char)c);
                }

                System.out.print(String.valueOf(buf));
            } catch (IOException ex) {
                Logger.getLogger(Mp3Handler.class.getName()).log(Level.SEVERE, null, ex);
            }
              
        }
        return null;
    }
    public static void main(String args[]){
        Mp3Handler mpe = new Mp3Handler();
        mpe.getDocument(new File("/media/TooZooFoo/音乐/Let_It_Be_Me.mp3"));
    }
}
